package com.woniu.controller;

import cn.dev33.satoken.util.SaResult;
import com.github.pagehelper.PageInfo;
import com.woniu.entity.dto.TestScoreDTO;
import com.woniu.service.TestScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 传入考试ID查询学生成绩，并进行排序，多条件查询
 */
@RestController
@RequestMapping("testScore")
public class TestScoreController {

    @Autowired
    private TestScoreService testScoreService;
    //通过考试ID查询所有学生成绩
    @PostMapping("/list")
    public SaResult findAllBycontestId(@RequestBody TestScoreDTO testScoreDTO){
        PageInfo<TestScoreDTO> contest = testScoreService.findAllBycontest(testScoreDTO);
        return SaResult.ok().setData(contest);
    }
    //通过考试ID查询所有班级和战队
    @GetMapping("/listGroup")
    public SaResult findAllGroupByContestId(@RequestParam Integer contestId){
        List<String> allGroup = testScoreService.findAllGroupByContestId(contestId);
        return SaResult.ok().setData(allGroup);
    }
}
